"""
Input:
5 7
1 2 0
4 5 0
2 3 0
1 2 1
2 3 1
4 5 1
1 5 1
Output:
We are a team
We are a team
We are a team
We are not a team

Input:
5 6
1 2 0
1 2 1
1 5 0
2 3 1
2 5 1
1 3 2
Ouput:
we are a team
we are not a team
we are a team
da pian zi
"""

"""
我用的字典，答案用的数组
"""
def main():
    # get input 
    num_people, num_msg = map(int, input().split())
    msgs = [list(map(int, input().split())) for _ in range(num_msg)]

    # check input scope
    if num_people < 1 or num_people >= 100000 or num_msg < 1 or num_msg >= 100000:
        print("Null")
        return

    #2. build group
    group = {} # k:v (people id : group id)
    group_id = 0
    for msg in msgs:
        p1, p2, c = msg
        if p1 < 1 or p1 > num_people or p2 < 1 or p2 > num_people:
            print("da pian zi")
            continue

        if c == 0: # build group
            if p1 not in group.keys() and p2 not in group.keys():
                group[p1] = group_id
                group[p2] = group_id
                group_id += 1
            elif p1 in group.keys() and p2 not in group.keys():
                group[p2] = group[p1]
            elif p1 not in group.keys() and p2 in group.keys():
                group[p1] = group[p2]
        
        elif c == 1: # check result
            if p1 in group.keys() and p2 in group.keys() and group[p1] == group[p2]:
                print("We are a team")
            else:
                print("We are not a team")

        else:
            print("da pian zi")


if __name__ == "__main__":
    main()